import NProgress from 'nprogress'; // progress bar
import 'nprogress/nprogress.css';

NProgress.configure({ showSpinner: false }); // NProgress Configuration

const onLoad = (importFun: () => Promise<any>) => {
  NProgress.start();
  return importFun().finally(() => {
    NProgress.done();
  });
};

export default function lazyLoadView(importFun: () => Promise<any>) {
  // return () =>
  //   new Promise((resolve, reject) => {
  //     NProgress.start();
  //     importFun()
  //       .then(resolve, reject)
  //       .finally(() => {
  //         NProgress.done();
  //       });
  //   });
  return onLoad.bind(null, importFun);
}
